{extend name="base"/}
{block name="resources"}
<style>
	.layui-layer-content {
		word-break: break-all;
		line-height: 24px;
	}
</style>
{/block}
{block name="main"}
<table id="version_list" lay-filter="version_list"></table>

<script type="text/html" id="operation">
    <div class="ns-table-btn">
        <a class="layui-btn" lay-event="basic">点击查看</a>
        <a class="layui-btn" lay-event="desc">更新说明</a>
    </div>
</script>

<script type="text/html" id="update_data">
	<div>{{d.version_desc}}</div>
</script>
{/block}
{block name="script"}
<script>
    layui.use(['form', 'laydate', 'laytpl'], function() {
        var table,
            laydate = layui.laydate,
			laytpl = layui.laytpl,
            form = layui.form;
        form.render();

        table = new Table({
            elem: '#version_list',
            url: ns.url("admin/system/upgrade"),
            parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "data": res.data //解析数据列表
                };
            },
            page: false,
            cols: [
                [{
                    field: 'version_name',
                    title: '更新包版本',
                    width: '25%',
                    unresize: 'false',
                    templet: function(data) {
                        return 'V' + data.version_name;
                    },
                }, {
                    field: 'version_release',
                    title: '更新包编号',
                    width: '25%',
                    unresize: 'false'
                }, {
                    field: 'create_time',
                    title: '发布时间',
                    width: '25%',
                    unresize: 'false',
                    templet: function(data) {
                        return ns.time_to_date(data.create_time);
                    },
                }, {
                    title: '操作',
                    width: '25%',
                    toolbar: '#operation',
                    unresize: 'false'
                }]
            ]
        });

        /**
         * 监听工具栏操作
         */
        table.tool(function(obj) {
            var data = obj.data,
                event = obj.event;
            switch (event) {
                case 'basic':
                    location.href = ns.url("admin/system/version" + "?version_release=" + data.version_release);
                    break;
                case 'desc':
					uploadData(data);
                    break;
            }
        });
		
		//详情
		function uploadData(data) {
			var uploadHtml = $("#update_data").html();
			laytpl(uploadHtml).render(data, function(html) {
				layer.open({
					type: 1,
					title: '更新说明',
					area: ['500px'],
					content: html
				});
			})
		}
    });
</script>
{/block}